/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var oTableAsignacion;
var tipo_confirmacion;
var vgl_var;
$(document).ready(function() {
      if( $('input[name="nombre_pagina"]').val() != null    ){
         oTable=$('#tableList').dataTable( {
               "bPaginate": true,
               "bLengthChange": false,
               "bFilter": true,
               "bSort": true,
               "bInfo": true,
               "bAutoWidth": false,
               "bDestroy":true,
               "sPaginationType": "full_numbers",
               //"sScrollY": "351px",
               "sAjaxSource": 'ServletDataTable?strpv_tipoListado=dtpv_tarea' ,
               "aoColumns": [
                   { "sTitle": "codigo_asignacion" , "bVisible": false },
                   { "sTitle": "Nombre","sClass": "alignLeft" },
                   { "sTitle": "Descripcion","sClass": "alignLeft" },
                   { "sTitle": "Fecha estimada" },
                   { "sTitle": "% avance" }
               ]
           });
        $('#tableList tbody').delegate("tr", "click", rowClick);
          
    }
    $( "#slider-range-min" ).slider({
        range: "min",
        value: 0,
        min: 0,
        max: 100,
        slide: function( event, ui ) {
            $( "#amount" ).val( ui.value );
        }
    });   
$( "#dialog-avance" ).dialog({
        title: "Porcentaje de avance",
        closeOnEscape: false,
        dialogClass: 'no-close',
        autoOpen: false,
        height:240,
        width: 600,
        modal: true,
        buttons: {
            "Cancelar": function() {
                $( this ).dialog( "close" );
               
            },
            "Guardar": function() {
                
                var mapParameter = {};
                mapParameter['metodo'] = 'actualizarPorcentajeAsignacion';
                mapParameter['strpv_codigoAsignacion'] = oTable.fnGetData(hlr)[0];
                mapParameter['strpv_porcentaje'] = $( "#amount" ).val();
                $.ajax({
                    url:  'ServletMantenimiento',
                    dataType: 'json',
                    data: mapParameter,  
                    success: function(data){
                       oTable.fnReloadAjax();
                       $( '#dialog-avance' ).dialog( "close" );
                    }
                });
                
                
            }
        }
   }).parent('.ui-dialog').find('.ui-dialog-titlebar-close').hide();    

   $('#btnMarcarAvance').click(function(){
        //var codigo = oTable.fnGetData(hlr)[0];
       $( "#amount" ).val( 0 );
       $( "#dialog-avance" ).dialog("open");
   });

  
});
